# Contributor: André Klitzing <aklitzing@@gmail.com>
# Maintainer: André Klitzing <aklitzing@gmail.com>
pkgname=croc
pkgver=10.0.11
pkgrel=0
pkgdesc="Easily and securely send things from one computer to another"
url="https://github.com/schollz/croc"
license="MIT"
arch="all"
makedepends="go"
subpackages="$pkgname-bash-completion $pkgname-zsh-completion"
source="https://github.com/schollz/croc/archive/refs/tags/v$pkgver/croc-$pkgver.tar.gz"
options="net" # fetch dependencies

# secfixes:
#   9.1.0-r0:
#     - CVE-2021-31603
#   10.0.11-0:
#     - CVE-2023-43617
#     - CVE-2023-43616
#     - CVE-2023-43618
#     - CVE-2023-43619
#     - CVE-2023-43620
#     - CVE-2023-43621

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -ldflags "-X github.com/schollz/croc/v${pkgver%%.*}/src/cli.Version=v$pkgver"
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/

	install -Dm644 src/install/bash_autocomplete \
		"$pkgdir"/usr/share/bash-completion/completions/croc
	install -Dm644 src/install/zsh_autocomplete \
		"$pkgdir"/usr/share/zsh/site-functions/_croc
}

sha512sums="
1cdfc5823e29406ec92ad4b24526e30032b89787d77382a0179c558cb2f0dd99556d93c7523ebfbb1dd4cac15ec596b3ddd0ce58ac5b9491f34b94436a20fbef  croc-10.0.11.tar.gz
"
